//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
using OpenLS.Drawing;

namespace OpenLS.Spreadsheet.UI
{
    abstract class StandardColorConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Workbook workbook = (Workbook)value;

            List<SpreadsheetColor> result = new List<SpreadsheetColor>();


            if (workbook != null)
            {
                foreach (ColorSchemeIndex i in Indexes)
                    result.Add(new ThemeColor(i, null));
                result.Add(new ThemeColor(ColorSchemeIndex.Dark1, 0.5));
                result.Add(new ThemeColor(ColorSchemeIndex.Light1, -0.05));
                foreach (ColorSchemeIndex i in Indexes2)
                    result.Add(new ThemeColor(i, 0.8));
                result.Add(new ThemeColor(ColorSchemeIndex.Dark1, 0.35));
                result.Add(new ThemeColor(ColorSchemeIndex.Light1, - 0.15));
                foreach (ColorSchemeIndex i in Indexes2)
                    result.Add(new ThemeColor(i, 0.6));
                result.Add(new ThemeColor(ColorSchemeIndex.Dark1, 0.25));
                result.Add(new ThemeColor(ColorSchemeIndex.Light1, - 0.25));
                foreach (ColorSchemeIndex i in Indexes2)
                    result.Add(new ThemeColor(i, 0.4));
                result.Add(new ThemeColor(ColorSchemeIndex.Dark1, 0.15));
                result.Add(new ThemeColor(ColorSchemeIndex.Light1, - 0.35));
                foreach (ColorSchemeIndex i in Indexes2)
                    result.Add(new ThemeColor(i, -0.25));
                result.Add(new ThemeColor(ColorSchemeIndex.Dark1, 0.05));
                result.Add(new ThemeColor(ColorSchemeIndex.Light1, - 0.5));
                foreach (ColorSchemeIndex i in Indexes2)
                    result.Add(new ThemeColor(i, -0.5));
            }
            result.Add(new RgbColor(Colors.DarkRed));
            result.Add(new RgbColor(Colors.Red));
            result.Add(new RgbColor(Colors.Orange));
            result.Add(new RgbColor(Colors.Yellow));
            result.Add(new RgbColor(Colors.LightGreen));
            result.Add(new RgbColor(Colors.Green));
            result.Add(new RgbColor(Colors.LightBlue));
            result.Add(new RgbColor(Colors.Blue));
            result.Add(new RgbColor(Colors.DarkBlue));
            result.Add(new RgbColor(Colors.Purple));
            result.Add(new AutomaticColor(ForFill));
            return result;
        }

        public abstract bool ForFill { get;}

        static readonly ColorSchemeIndex[] Indexes = new ColorSchemeIndex[]
            {
                ColorSchemeIndex.Dark1,
                ColorSchemeIndex.Light1,
                ColorSchemeIndex.Dark2,
                ColorSchemeIndex.Light2,
                ColorSchemeIndex.Accent1,
                ColorSchemeIndex.Accent2,
                ColorSchemeIndex.Accent3,
                ColorSchemeIndex.Accent4,
                ColorSchemeIndex.Accent5,
                ColorSchemeIndex.Accent6,
            };
        static readonly ColorSchemeIndex[] Indexes2 = new ColorSchemeIndex[]
            {
                ColorSchemeIndex.Dark2,
                ColorSchemeIndex.Light2,
                ColorSchemeIndex.Accent1,
                ColorSchemeIndex.Accent2,
                ColorSchemeIndex.Accent3,
                ColorSchemeIndex.Accent4,
                ColorSchemeIndex.Accent5,
                ColorSchemeIndex.Accent6,
            };
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }

        #endregion
    }
}
